#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char arr[1001];
	int n;
	cin >> arr;
	int len = strlen(arr);
	int sum = 0;
	for (int i = 0; i < len; i++) {
		if (arr[i] >= '0' && arr[i] <= '9') {
			sum = sum * 16 + arr[i] - '0';
		}
		else {
			sum = sum * 16 + arr[i] - 'A' + 10;
		}
    }
	cout << sum << endl;
	return 0;
}